#include <iostream>
#include <algorithm>
#include "DoubleLinkedList.h"

bool check = true;

List<int>::iterator find( List<int>& _list , const int& _val )
{
  check = true;
  int count = 1;
  List<int>::iterator itr = _list.begin();
  while ( *(++itr) != _val && itr != _list.end() ) { count++; }
  if ( count == _list.size() )
    {
      std::cout << "Not find ,iter is the tail Node of the list." << std::endl;
      check = false;
    }
  return itr;
};

int main()
{
  List<int> L;
  L.push_back(1);
  L.push_back(2);
  L.push_back(3);
  L.push_back(4);
  L.push_back(5);
  List<int>::iterator itr = L.begin() , iter;
  while ( itr != L.end() )
    {
      std::cout << *itr << " ";
      ++itr;
    }
  std::cout << std::endl;
  iter = find( L , 3 );
  if ( check )
    { L.erase( iter ); }
  itr = L.begin();
  while ( itr != L.end() )
    {
      std::cout << *itr <<" ";
      ++itr;
    }
  std::cout << std::endl;
  iter = find( L , 3 );
  L.~List();
  return 0;
}
